﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using DataModels;
using Nuclex.Game.States;
using WindowsGameLibrary1;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Media;

using Nuclex.Input;

namespace TowerAssault
{
    public class SplashScreenState : PlayGameState
    {
        private Microsoft.Xna.Framework.Content.ContentManager Content;
        //private InputHandler input;
        private ComputerInput input;
        private InputManager nuclexInput;
        //private SolGUIManager _GUIManager;
        private SpriteBatch sb;
        private GraphicsDevice gd;
        private SoundManager sound;
        SpriteFont font;
        SpriteFont bigFont;
        StateManager sm;
        //SolInputToAction inputToAction;
        Texture2D splashScreenBase;

        InputProcesser inputProcesser;


        GameServices services;

        public SplashScreenState(StateManager stateManager, GameServices services)
            : base(stateManager)
        {
            this.services = services;
            sm = stateManager;
            inputProcesser = new InputProcesser();
        }

        private void inputHelper(GameTime gameTime)
        {
            //if (input.isMouseLeftButtonUpClick())
            //{
            //    // go to actual game;
            //    gameStateManager.Push(new SolPlayGameState(sm));
            //}
        }

        public override void Update(GameTime gameTime)
        {
            inputHelper(gameTime);
            //inputToAction.inputHelper(gameTime);
        }

        /// <summary>This is called when the game state should draw itself</summary>
        /// <param name="gameTime">Provides a snapshot of timing values</param>
        public override void Draw(GameTime gameTime)
        {
            gd.Clear(Color.DimGray);
            sb.Draw(splashScreenBase, new Rectangle(0, 0, 256, 256), Color.White);

            //_GUIManager.drawGUI(sb);
            //sb.DrawString(bigFont,
            //        "Marines Of SOL " ,
            //         new Vector2(20, 20), Color.Violet);
            //sb.DrawString(font,
            //    "Click the mouse to begin ",
            //    new Vector2(80, 80), Color.Violet);

        }

        private void setupClassVar(){
            input = ComputerInput.getComputerInput();
            sb = services.getSpriteBatch();
            gd = services.getGraphicsDevice();
            sound = services.getSound();
            //Content = services.getContent();
            //input = ((StateManager)base.gameStateManager).getGameInputHandler();
            //nuclexInput = ((StateManager)base.gameStateManager).getNuclexInput();

            DataLoader dataLoader = services.getDataLoader();
            font = dataLoader.loadFont("SpriteFont1");
            splashScreenBase = dataLoader.loadTexture("Splash");
        }

        /// <summary>Called when the game state has been entered</summary>
        protected override void OnEntered()
        {
            setupClassVar();
            
            //--------------------start loading sound------------------

            //dataLoader.loadSound(services.getSound());
            //services.getSound().playSong(0);
            //_GUIManager = new SolGUIManager(font, sb);
            //SolActionToGUI actionToGUI = new SolActionToGUI(_GUIManager, services.getSound());
            //dataLoader.loadSplashGUI(_GUIManager, gd);
            //SolMicroGameStateManager microGameStateManager = new SolMicroGameStateManager(actionToField, actionToGUI);
            //SolAction solAction =
                //new SolAction(null, null,
                //actionToGUI, null, sm, services.getTempSave(), null, services, null);
            //inputToAction = new SolInputToAction(null, actionToGUI, solAction, null, null);
        }

        /// <summary>Called when the game state is being left again</summary>
        protected override void OnLeaving() { }

        /// <summary>Called when the game state should enter pause mode</summary>
        protected override void OnPause() { }

        /// <summary>Called when the game state should resume from pause mode</summary>
        protected override void OnResume() { }
    }
}
